package com.yunshan.mp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.mp.domain.MpIndexActivityNotice;
import com.yunshan.mp.service.IMpIndexActivityNoticeService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 活动公告Controller
 * 
 * @author yunshan
 * @date 2025-01-20
 */
@Api(tags = "活动公告")
@RestController
@RequestMapping("/mp/activityNotice")
public class MpIndexActivityNoticeController extends BaseController
{
    @Autowired
    private IMpIndexActivityNoticeService mpIndexActivityNoticeService;

    /**
     * 查询活动公告列表
     */
    @ApiOperation("查询活动公告列表")
    @GetMapping("/list")
    public TableDataInfo list(MpIndexActivityNotice mpIndexActivityNotice)
    {
        startPage();
        List<MpIndexActivityNotice> list = mpIndexActivityNoticeService.selectMpIndexActivityNoticeList(mpIndexActivityNotice);
        return getDataTable(list);
    }

    /**
     * 导出活动公告列表
     */
    @ApiOperation("导出活动公告列表")
    @Log(title = "活动公告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MpIndexActivityNotice mpIndexActivityNotice)
    {
        List<MpIndexActivityNotice> list = mpIndexActivityNoticeService.selectMpIndexActivityNoticeList(mpIndexActivityNotice);
        ExcelUtil<MpIndexActivityNotice> util = new ExcelUtil<MpIndexActivityNotice>(MpIndexActivityNotice.class);
        util.exportExcel(response, list, "活动公告数据");
    }

    /**
     * 获取活动公告详细信息
     */
    @ApiOperation("获取活动公告详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mpIndexActivityNoticeService.selectMpIndexActivityNoticeById(id));
    }

    /**
     * 新增活动公告
     */
    @ApiOperation("新增活动公告")
    @Log(title = "活动公告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MpIndexActivityNotice mpIndexActivityNotice)
    {
        return toAjax(mpIndexActivityNoticeService.insertMpIndexActivityNotice(mpIndexActivityNotice));
    }

    /**
     * 修改活动公告
     */
    @ApiOperation("修改活动公告")
    @Log(title = "活动公告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MpIndexActivityNotice mpIndexActivityNotice)
    {
        return toAjax(mpIndexActivityNoticeService.updateMpIndexActivityNotice(mpIndexActivityNotice));
    }

    /**
     * 删除活动公告
     */
    @ApiOperation("删除活动公告")
    @Log(title = "活动公告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mpIndexActivityNoticeService.deleteMpIndexActivityNoticeByIds(ids));
    }
}
